package com.aplikata.evok.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.aplikata.evok.bo.PatientAttachement;
import com.aplikata.service.PublicService;
import com.aplikata.util.StringUtil;

/**
 * @ClassName: PatientAttachementDataModel
 * @Description: TODO
 * @author Jasenko
 * @date 21. 9. 2012. 11:41:07
 */
public class PatientAttachementDataModel extends ListDataModel<PatientAttachement> implements SelectableDataModel<PatientAttachement> {
	private PublicService publicService;

	public PatientAttachementDataModel() {
	}

	public PatientAttachementDataModel(PublicService publicService, List<PatientAttachement> data) {
		super(data);
		this.publicService = publicService;
	}

	@Override
	public PatientAttachement getRowData(String arg0) {
		if (StringUtil.isStrEmpty(arg0) || "null".equals(arg0))
			return null;

		return (PatientAttachement) publicService.get(PatientAttachement.class, Long.parseLong(arg0));
	}

	@Override
	public Object getRowKey(PatientAttachement pa) {
		return pa.getId();
	}

	public PublicService getPublicService() {
		return publicService;
	}

	public void setPublicService(PublicService publicService) {
		this.publicService = publicService;
	}

}